#Human body infrared sensor & PiCamera

import RPi.GPIO as GPIO
import time
import picamera

def init():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(18,GPIO.IN)
    pass

def detct():
    while True:
        curtime = time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time()))
        if GPIO.input(18) == True:
            alart(curtime)
        else:
            continue
        time.sleep(0.01)

def alart(curtime):
    print curtime + " Someone is coming!"
    camera.capture(curtime + '.jpg')

camera = picamera.PiCamera()

time.sleep(1)

init()
detct()
GPIO.cleanup()
